using Unity.Collections;
using Unity.Entities;
using Unity.Transforms;

namespace Game.Core
{
    public partial struct HealthInfoRefreshJob : IJobEntity
    {
        [ReadOnly] public ComponentLookup<Damageable> Damageables;

        void Execute(Entity entity, in Parent parent, ref HealthPointRatio healthPointRatio)
        {
            Damageable damageable = Damageables[parent.Value];
            // Debug.Log($"HP cur->{data.Current.CurHealthPoint} max->{data.Current.MaxHealthPoint} ratio->{healthPointRatio.Value}");
            healthPointRatio.Value = damageable.Detail.MaxHealthPoint > 0
                ? damageable.Detail.CurHealthPoint / damageable.Detail.MaxHealthPoint
                : 1;
        }
    }
}